﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;

namespace GiveGraphModel
{
    public class Event
    {
        public virtual int EventId { get; set; }
        public virtual DateTime StartDate { get; set; }
        public virtual DateTime EndDate { get; set; }

        public virtual string Description { get; set; }
        public virtual Location Location { get; set; }

        public virtual ICollection<ServiceRequest> Requests { get; set; }
        public virtual ICollection<Organization> Hosts { get; set; }
    }

    public sealed class EventConfiguration : EntityTypeConfiguration<Event>
    {
        public EventConfiguration()
        {


            Property(e => e.Description)
                    .IsRequired();
            
            HasRequired(e => e.Location);
            HasRequired(e => e.Hosts);
            
            HasMany(e=>e.Requests)
                    .WithOptional();


        }
    }
}
